//
//  BindPhoneView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/10/11.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class BindPhoneView: UIView {
    
    fileprivate let font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))

    let imageCodeBtn = UIButton()
    let phoneCodeBtn = UIButton()
    let confirmBtn = UIButton()
    let rebindView = UITextField()
    let imageCodeView = UITextField()
    let phoneCodeView = UITextField()
    
    init() {
        super.init(frame: .zero)
        
        self.backgroundColor = UIColor.editColor()
        
        let bindLabel = UILabel()
        bindLabel.text = tiedNumber + "："
        bindLabel.textAlignment = .right
        bindLabel.font = font
        self.addSubview(bindLabel)
        
        let phoneLabel = UILabel()
        phoneLabel.text = KMTool.stringForEnumKey(.phone)
        phoneLabel.textAlignment = .right
        phoneLabel.font = font
        self.addSubview(phoneLabel)
        
        let rebindLabel = UILabel()
        rebindLabel.text = rebindNumber + "："
        rebindLabel.textAlignment = .right
        rebindLabel.font = font
        self.addSubview(rebindLabel)
        
        
        rebindView.keyboardType = .numberPad
        rebindView.layer.borderColor = UIColor.lineColor().cgColor
        rebindView.layer.borderWidth = 1
        rebindView.textAlignment = .center
        rebindView.font = font
        self.addSubview(rebindView)
        
        let imageCodeLabel = UILabel()
        imageCodeLabel.text = imageCode + "："
        imageCodeLabel.textAlignment = .right
        imageCodeLabel.font = font
        self.addSubview(imageCodeLabel)
        
        
        imageCodeView.layer.borderColor = UIColor.lineColor().cgColor
        imageCodeView.layer.borderWidth = 1
        imageCodeView.textAlignment = .center
        imageCodeView.font = font
        self.addSubview(imageCodeView)
        
        self.addSubview(imageCodeBtn)
        
        let phoneCodeLabel = UILabel()
        phoneCodeLabel.text = phoneCode + "："
        phoneCodeLabel.textAlignment = .right
        phoneCodeLabel.font = font
        self.addSubview(phoneCodeLabel)
        
        
        phoneCodeView.layer.borderColor = UIColor.lineColor().cgColor
        phoneCodeView.layer.borderWidth = 1
        phoneCodeView.font = font
        phoneCodeView.textAlignment = .center
        self.addSubview(phoneCodeView)
        
        phoneCodeBtn.setTitle(getCode, for: .normal)
        phoneCodeBtn.backgroundColor = UIColor.red
        phoneCodeBtn.titleLabel?.font = font
        self.addSubview(phoneCodeBtn)
        
        confirmBtn.backgroundColor = UIColor.red
        confirmBtn.setTitle(confirmBinding, for: .normal)
        confirmBtn.titleLabel?.font = font
        confirmBtn.layer.cornerRadius = 5
        confirmBtn.layer.masksToBounds = true
        self.addSubview(confirmBtn)
        
        bindLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.equalToSuperview().offset(RATIO_H(maxNum: 40))
            make.width.equalTo(RATIO(maxNum: 140))
            make.height.greaterThanOrEqualTo(10)
        }
        
        phoneLabel.snp.makeConstraints { (make) in
            make.left.equalTo(bindLabel.snp.right)
            make.centerY.equalTo(bindLabel)
            make.height.equalTo(bindLabel)
            make.width.greaterThanOrEqualTo(10)
        }
        
        rebindLabel.snp.makeConstraints { (make) in
            make.left.equalTo(bindLabel)
            make.width.equalTo(bindLabel)
            make.top.equalTo(bindLabel.snp.bottom).offset(RATIO_H(maxNum: 40))
            make.height.greaterThanOrEqualTo(10)
        }
        
        rebindView.snp.makeConstraints { (make) in
            make.left.equalTo(rebindLabel.snp.right)
            make.centerY.equalTo(rebindLabel)
            make.width.equalTo(RATIO(maxNum: 200))
            make.height.equalTo(RATIO_H(maxNum: 35))
        }
        
        imageCodeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(rebindLabel)
            make.top.equalTo(rebindLabel.snp.bottom).offset(RATIO_H(maxNum: 40))
            make.width.equalTo(rebindLabel)
            make.height.greaterThanOrEqualTo(10)
        }
        
        imageCodeView.snp.makeConstraints { (make) in
            make.centerY.equalTo(imageCodeLabel)
            make.left.equalTo(imageCodeLabel.snp.right)
            make.width.equalTo(RATIO(maxNum: 100))
            make.height.equalTo(rebindView)
        }
        
        imageCodeBtn.snp.makeConstraints { (make) in
            make.left.equalTo(imageCodeView.snp.right)
            make.centerY.width.height.equalTo(imageCodeView)
        }
        
        phoneCodeLabel.snp.makeConstraints { (make) in
            make.top.equalTo(imageCodeLabel.snp.bottom).offset(RATIO_H(maxNum: 40))
            make.left.equalTo(imageCodeLabel)
            make.width.equalTo(imageCodeLabel)
            make.height.greaterThanOrEqualTo(10)
        }
        
        phoneCodeView.snp.makeConstraints { (make) in
            make.centerY.equalTo(phoneCodeLabel)
            make.left.equalTo(phoneCodeLabel.snp.right)
            make.width.equalTo(imageCodeView)
            make.height.equalTo(imageCodeView)
        }
        
        phoneCodeBtn.snp.makeConstraints { (make) in
            make.left.equalTo(phoneCodeView.snp.right)
            make.centerY.height.equalTo(phoneCodeView)
            make.width.equalTo(imageCodeBtn)
        }
        
        confirmBtn.snp.makeConstraints { (make) in
            make.top.equalTo(phoneCodeLabel.snp.bottom).offset(RATIO_H(maxNum: 40))
            make.centerX.equalToSuperview()
            make.width.equalTo(RATIO(maxNum: 100))
            make.height.equalTo(RATIO_H(maxNum: 35))
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    

}
